package pers.gxm.bridge;

public class StringDisplayImpl extends DisplayImpl {
    public static void main(String[] args) {
//        Display d1 = new Display(new StringDisplayImpl("Hello,World!"));
//        Display d2 = new CountDisplay(new StringDisplayImpl("Hi,my"));
//        CountDisplay d3 = new CountDisplay(new StringDisplayImpl("Hello,China"));
//        d1.display();
//        d2.display();
//        d3.display();
//        d3.multiDisplay(7);
        RandomDisplay d1 = new RandomDisplay(new StringDisplayImpl("Hello,World!"));
        d1.randomDisplay(10);

    }

    private String string;
    private int width;
    public StringDisplayImpl(String string){
        this.string = string;
        this.width = string.getBytes().length;
    }
    @Override
    public void rawOpen() {
        printLine();
    }

    @Override
    public void rawPrint() {
        System.out.println("|" + string + "|");
    }

    @Override
    public void rawClose() {
        printLine();
    }

    private void printLine(){
        System.out.print("+");
        for(int i = 0; i <width;i++){
            System.out.print("-");
        }
        System.out.print("+\n");
    }
}
